<?php
declare(strict_types=1);

namespace app\service;

use app\common\BaseService;
use app\model\Role;


class RoleService extends BaseService
{
    public function __construct()
    {
        $this->model = new Role();
    }

    //创建roleWithRoutes方法
    public function roleWithRoutes()
    {
        //获取所有角色组列表
        $result = $this->getListAll()->toArray();
        foreach ($result as &$item){
            $routes = (new RoutesService())->routesByRules($item['rules']);
            $item['routes'] = $routes;
        }
        return $result;
    }

}